package cn.gok.util;

import java.util.*;

/**
 * @ClassName Collections工具类
 * @Description TODO
 * @Author HP
 * @Date 14:37 2022/7/11
 * @Version 1.0
 **/
public class Collections工具类 {
    public static void main(String[] args) {
        常用方法();
    }

    private static void 常用方法() {
        List<Integer> list = Arrays.asList(10,8,19,2,13);
        Collections.sort(list);
        System.out.println(list);
        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                if (o1>o2){
                    return -1;
                }
                return 1;
            }
        });
        System.out.println(list);
        List<Integer> list1= new ArrayList<>(list);
        Collections.addAll(list1,100,103,107);
        Collections.reverse(list1);
        System.out.println(list1);
        System.out.println(Collections.frequency(list1,2));
        Collections.fill(list1,1);
        System.out.println(list1);


    }

}
